package utils;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

public class ResponseBodyUtil {
	 public static void sendJsonObject(HttpServletResponse response,AJAXResult ret){
		 response.setContentType("application/json; charset=utf-8");
		 response.setHeader("cache-control", "no-cache");
		 String json = JSON.toJSONString(ret);
		 PrintWriter out;
		try {
			out = response.getWriter();
			out.print(json);
			out.flush();
		}
		catch (IOException e) {
			e.printStackTrace();
		}		 
	 }
	 public static void sendJsonObject(HttpServletResponse response,Object ret){
		 response.setContentType("application/json; charset=utf-8");
		 response.setHeader("cache-control", "no-cache");
		 String json = JSON.toJSONString(ret);
		 PrintWriter out;
		try {
			out = response.getWriter();
			out.print(json);
			out.flush();
		}
		catch (IOException e) {
			e.printStackTrace();
		}		 
	 }
}
